﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ERF.Menu
{
    /// <summary>
    /// This is the base class of all menu items. It has
    /// a title and a method to call when you call the
    /// submit method.
    /// </summary>

    public class MenuItem
    {
        public delegate void MenuAction();

        private String title;
        protected MenuAction action;

        /// <summary>
        /// Creates a menu item and wants a title and a action
        /// </summary>
        public MenuItem(String title, MenuAction action)
        {
            this.title = title;
            this.action = action;
        }
        /// <summary>
        /// Use this constructor when you want to inherit this class
        /// and want your class to define it's own action.
        /// </summary>
        protected MenuItem(String title)
        {
            this.title = title;
        }
        /// <summary>
        /// Gets the title of the current menu item
        /// </summary>
        public String Title
        {
            get { return title; }
        }

        /// <summary>
        /// Submits this menu item's action method.
        /// </summary>
        public void Submit()
        {
            if(this.action != null)
                this.action();
        }
    }
}
